home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / CPOGE4 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.3 KB  |  49 lines

  1. package sun.net.www.protocol.systemresource;
  2.  
  3. import java.net.URL;
  4.  
  5. class ParseSystemURL {
  6.    private String base;
  7.    private String member;
  8.    private boolean isAFile;
  9.    private boolean isInZip;
  10.  
  11.    public ParseSystemURL(URL url) {
  12.       String file = url.getFile();
  13.       if (file.startsWith("/FILE")) {
  14.          this.isAFile = true;
  15.          file = file.substring(5);
  16.       } else {
  17.          if (!file.startsWith("/ZIP")) {
  18.             return;
  19.          }
  20.  
  21.          this.isInZip = true;
  22.          file = file.substring(4);
  23.       }
  24.  
  25.       this.base = file.substring(0, file.indexOf("/+/"));
  26.       this.member = file.substring(file.indexOf("/+/") + 3);
  27.    }
  28.  
  29.    public String getBase() {
  30.       return this.base;
  31.    }
  32.  
  33.    public String getMember() {
  34.       return this.member;
  35.    }
  36.  
  37.    public boolean isFile() {
  38.       return this.isAFile;
  39.    }
  40.  
  41.    public boolean isValid() {
  42.       return this.isAFile || this.isInZip;
  43.    }
  44.  
  45.    public boolean isZip() {
  46.       return this.isInZip;
  47.    }
  48. }
  49.